$(document)
    .ready(
        function () {
            // Multi select//属性标签
            var config = {
                '.chosen-select': {},
                '.chosen-select-deselect': {
                    allow_single_deselect: true
                },
                '.chosen-select-no-single': {
                    disable_search_threshold: 10
                },
                '.chosen-select-no-results': {
                    no_results_text: 'Oops, nothing found!'
                },
                '.chosen-select-width': {
                    width: "100%"
                }
            };
            for (var selector in config) {
                $(selector).chosen(config[selector]);
            }

            Date.prototype.pattern = function (fmt) {

                var o = {
                    "M+": this.getMonth() + 1, // 月份
                    "d+": this.getDate(), // 日
                    "h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12, // 小时
                    "H+": this.getHours(), // 小时
                    "m+": this.getMinutes(), // 分
                    "s+": this.getSeconds(), // 秒
                    "q+": Math.floor((this.getMonth() + 3) / 3), // 季度
                    "S": this.getMilliseconds() // 毫秒
                };
                var week = {
                    "0": "/u65e5",
                    "1": "/u4e00",
                    "2": "/u4e8c",
                    "3": "/u4e09",
                    "4": "/u56db",
                    "5": "/u4e94",
                    "6": "/u516d"
                };
                if (/(y+)/.test(fmt)) {
                    fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
                }
                if (/(E+)/.test(fmt)) {
                    fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "/u661f/u671f" : "/u5468") : "") + week[this.getDay() + ""]);
                }
                for (var k in o) {
                    if (new RegExp("(" + k + ")").test(fmt)) {
                        fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
                    }
                }
                var str = fmt.lastIndexOf("N");
                if (str != -1) {
                    return "";
                }

                return fmt;
            }

            var _class = '已支付待开始';
            var type = "";
            /* Init DataTables */
            var oTable = $('#editable').DataTable();

            /*******************************************************************
             * 自己封装的js start **
             ******************************************************************/
            /** *************************初始函数*********************** */
            function init() {
                // 订单类型被点击的时候
                $('#ul_id li a').click(function () {
                    $('#ul_id li').removeClass('active');
                    $(this).parent().addClass('active');
                    _class = $(this).context.innerHTML;


                });
                coachList();
                // 加载团课已支付待开始 table
                _class = "已支付待开始";
                type = requestType(_class);
                getTKTable(_class, type, 1, "", "");
                // 门店
                $.ajax({
                    url: 'getStoreList.action',//
                    data: "",
                    type: 'post',
                    cache: false,
                    dataType: 'json',
                    success: function (data) {
                        var dataL = data.data;
                        var bool = data.ret;
                        var list = '';
                        $(".store_list").empty();
                        var options = '<option value="0">全部</option>';
                        if (bool == 0 || bool == '0') {
                            for (var i = 0; i < dataL.length; i++) {
                                var datas = dataL[i];
                                options = options + '<option value="'
                                    + datas.code + '">'
                                    + datas.name + '</option>';
                            }

                        }
                        // 团课
                        $(".store_list").append(options);
                        $(".store_list").trigger("chosen:updated");
                        $(".store_list").chosen();

                    },
                    error: function () {
                        alert("页面数据加载失败！");
                    }
                });
            }

            /** *******************团课订单类型被点击的时候触发的事件*********** */
            $("#ul_id li").click(
                function () {
                    stortList();
                    coachList();
                    $(this).addClass("active").siblings()
                        .removeClass("active");
                    _class = $(this).context.innerHTML;
                    type = requestType(_class);
                    $("#order_type_child").val(type);
                    getTKTable(_class, type, 1, "");

                });
            // 执行初始化函数
            init();
            miaodian();
            /** ***************************点击查询按钮的时候***************************** */
            // 团课查询按钮
            $("#but_submit").click(function () {
                var tradeId = $("#tk_tradeId").val();
                var _time = $("#tk_time").val();
                var str = _time.split("~");
                var c_start_time = str[0];
                var c_end_time = str[1];
                var course_id = $("#tk_course").val();
                var mobile = $("#tk_mobile").val();
                var store_id = $("#tk_store_list").val();
                var click_order_type = $("#click_order_type").val();
                var order_type_child = $("#order_type_child").val();
                var coach_id = $("#tk_coach_list").val();
                var userId = $("#tk_userId").val();
                var userName = $("#tk_userName").val();
                if (store_id == "0" || store_id == 0) {
                    store_id = "";
                }
                var datas = {
                    "course_stime": c_start_time,
                    "course_etime": c_end_time,
                    "course_id": course_id,
                    "mobile": mobile,
                    "store_id": store_id,
                    "type": order_type_child,
                    "tradeId": tradeId,
                    "coach_id": coach_id,
                    "userId":userId,
                    "userName":userName
                }
                getTKTable(click_order_type, order_type_child, 1, datas, "");
            });
            // 2私教查询
            $("#btn_sj_select").click(function () {
                var tradeId = $("#sj_tradeId").val();
                var _time = $("#sj_time").val();
                var str = _time.split("~");
                var c_start_time = str[0];
                var c_end_time = str[1];
                var course_id = $("#sj_course").val();
                var mobile = $("#sj_mobile").val();
                var store_id = $("#sj_store_list").val();
                var click_order_type = $("#click_order_type").val();
                var order_type_child = $("#order_type_child").val();
                var coach_id = $("#sj_coach_list").val();
                var userId = $("#sj_userId").val();
                var userName = $("#sj_userName").val();
                if (store_id == "0" || store_id == 0) {
                    store_id = "";
                }
                var datas = {
                    "course_stime": c_start_time,
                    "course_etime": c_end_time,
                    "course_id": course_id,
                    "mobile": mobile,
                    "store_id": store_id,
                    "type": order_type_child,
                    "tradeId": tradeId,
                    "coach_id": coach_id,
                    "userId":userId,
                    "userName":userName
                }
                getSJTable(click_order_type, order_type_child, 1, datas, "");
            });
            // 3檬营查询按钮
            $("#btn_my_select").click(function () {
                var _time = $("#my_time").val();
                var tradeId = $("#my_tradeId").val();
                var str = _time.split("~");
                var c_start_time = str[0];
                var c_end_time = str[1];
                var course_id = $("#my_course").val();
                var mobile = $("#my_mobile").val();
                var store_id = $("#my_store_list").val();
                var click_order_type = $("#click_order_type").val();
                var order_type_child = $("#order_type_child").val();
                var userId = $("#my_userId").val();
                var userName = $("#my_userName").val();
                if (store_id == "0" || store_id == 0) {
                    store_id = "";
                }
                var datas = {
                    "course_stime": c_start_time,
                    "course_etime": c_end_time,
                    "course_id": course_id,
                    "mobile": mobile,
                    "store_id": store_id,
                    "type": order_type_child,
                    "tradeId": tradeId,
                    "userId":userId,
                    "userName":userName
                }
                getMYTable(click_order_type, order_type_child, 1, datas, "");

            });
            // 4 自助健身按钮
            $("#btn_zz_select").click(function () {
                var tradeId = $("#zz_tradeId").val();
                var _time = $("#zz_time").val();
                var str = _time.split("~");
                var c_start_time = str[0];
                var c_end_time = str[1];
                var course_id = $("#zz_course").val();
                var mobile = $("#zz_mobile").val();
                var store_id = $("#zz_stort_list").val();
                var click_order_type = $("#click_order_type").val();
                var order_type_child = $("#order_type_child").val();
                var userId = $("#zz_userId").val();
                var userName = $("#zz_userName").val();
                if (store_id == "0" || store_id == 0) {
                    store_id = "";
                }
                var datas = {
                    "course_stime": c_start_time,
                    "course_etime": c_end_time,
                    "course_id": course_id,
                    "mobile": mobile,
                    "store_id": store_id,
                    "type": order_type_child,
                    "tradeId": tradeId,
                    "userId":userId,
                    "userName":userName
                }
                getZZTable(click_order_type, order_type_child, 1, datas, "");

            });
            // Ajax 统一方法
            // 6 用户订单明细按钮
            $("#btn_user_select").click(function () {
                var userId = $("#u_userId").val().trim();
                var mobile = $("#u_mobile").val().trim();
                var nickName = $("#u_nickName").val().trim();
                var pay_status = $("#user_pay_status").val();
                var pageNo = $("#u_pageNo").val().trim();
                if (pay_status == "0" || pay_status == 0) {
                	pay_status = "";
                }
                debugger;
                var datas = {
                    "userId": userId,
                    "mobile": mobile,
                    "nickName": nickName,
                    "payStatus": pay_status,
                    "pageNo":pageNo
                }
                getUserTable("", "", 1, datas, "");

            });
            /** **************课程类型 start***************** */
            $("#order_type li a").click(function () {
                var pageNum = 1;
                _class = $(this).context.innerHTML;
                $('title').text(_class);
                $("#order_title strong").text($(this).text());
                var url = "getOrderList.action";
                var data = null;
                $("#click_order_type").val(_class);
                if (_class == "私教课程") {
                    getSJTable(_class, "1", pageNum, "");
                }
                if (_class == "团体课程") {
                    getTKTable(_class, "1", pageNum, "");
                }
                if (_class == "檬营课程") {
                    getMYTable(_class, "1", pageNum, "");
                }
                if (_class == "自助健身") {
                    getZZTable(_class, "1", pageNum, "", "");
                }

            });
            /** **************课程类型 end***************** */
            /** *****************订单状态类型start********************* */
            $("#sijia li a").click(function () {
                $('#sijia li').removeClass('active');
                $(this).parent().addClass('active');
                $(this).context.innerHTML;
                _type = $(this).context.innerHTML;
                _type = siJiaoType(_type);
                // debugger;
                $("#order_type_child").val(_type);
                getSJTable(_class, _type, 1, "");

            });
            // 檬营订单类型被点击的时候
            $("#myType li a").click(function () {
                $('#myType li').removeClass('active');
                $(this).parent().addClass('active');
                $(this).context.innerHTML;
                _type = $(this).context.innerHTML;
                _type = myType(_type);
                $("#order_type_child").val(_type);
                getMYTable(_class, _type, 1, "");
            });

            // 自助健身
            $("#zizhuType li a").click(function () {
                $('#zizhuType li').removeClass('active');
                $(this).parent().addClass('active');
                _type = $(this).context.innerHTML;
                _type = zizhuType(_type);
                $("#order_type_child").val(_type);
                getZZTable(_class, _type, 1, "", "");
            });
            /** *****************订单状态类型end********************* */

            function requestType(type) {
                if (type == '<a href="#">已支付待开始</a>' || type == '已支付待开始') {
                    return "1";
                }
                if (type == '<a href="#">已支付排队中</a>' || type == '已支付排队中') {
                    return "2";
                }
                if (type == '<a href="#">已结束</a>' || type == '已结束') {
                    return "3";
                }
                if (type == '<a href="#">主动取消</a>' || type == '主动取消') {
                    return "4";
                }
                if (type == '<a href="#">待支付</a>' || type == '待支付') {
                    return "5";
                }
                if (type == '<a href="#">已退款</a>' || type == '已退款') {
                    return "6";
                }
                if (type == '<a href="#">被动取消</a>' || type == '被动取消') {
                    return "7";
                }

            }

            // 私教课程
            function siJiaoType(type) {
                if (type == "已支付" || type == '<a href="#">已支付</a>') {
                    return "1";
                }
                if (type == "已结束" || type == '<a href="#">已结束</a>') {
                    return "2";
                }
                if (type == "待支付" || type == '<a href="#">待支付</a>') {
                    return "3";
                }
                if (type == "已退款" || type == '<a href="#">已退款</a>') {
                    return "4";
                }
            }

            // 檬营课程 
            function myType(type) {
                if (type == "已支付▪成营" || type == '<a href="#">已支付▪成营</a>') {
                    return "1";
                }
                if (type == "已支付▪未成营" || type == '<a href="#">已支付▪未成营</a>') {
                    return "2";
                }
                if (type == "已结束" || type == '<a href="#">已结束</a>') {
                    return "3";
                }
                if (type == "待支付" || type == '<a href="#">待支付</a>') {
                    return "4";
                }
                if (type == "被动取消" || type == '<a href="#">被动取消</a>') {
                    return "5";
                }
                if (type == "已退款" || type == '<a href="#">已退款</a>') {
                    return "6";
                }
                if (type == "主动取消" || type == '<a href="#">主动取消</a>') {
                    return "7";
                }
                if (type == "已支付▪成营排队中" || type == '<a href="#">已支付▪成营排队中</a>') {
                    return "9";
                }
            }

            // 自助健身课程
            function zizhuType(type) {
                if (type == "已支付" || type == '<a href="#">已支付</a>') {
                    return "1";
                }
                if (type == "已结束" || type == '<a href="#">已结束</a>') {
                    return "2";
                }
                if (type == "待支付" || type == '<a href="#">待支付</a>') {
                    return "3";
                }
                if (type == "已取消" || type == '<a href="#">已取消</a>') {
                    return "4";
                }
                if (type == "已退款" || type == '<a href="#">已退款</a>') {
                    return "5";
                }
            }

            /** ***************定义显示的table******************** */


            /** *************************订单取消****************************** */

            function delete_video(id) {
                swal({
                    title: "确定删除吗?",
                    text: "删除后不可恢复!",
                    type: "warning",
                    showCancelButton: true,
                    cancelButtonText: "容我三思！",
                    confirmButtonText: "删除!",
                }).then(function () {
                    swal("删除成功!", "", "success");
                }, function () {
        		});

            }

            /** *************************销课****************************** */
            function courseDispel(orderId, type) {
                var data = {
                    "orderId": orderId,
                    "type": type
                }
                Ajax("updateOrder", data, function (datas) {
                    var data = datas;
                    if (datas.ret == '-1') {
                        alert(datas.msg);
                    } else {
                        alert(datas.msg);
                    }
                });
            }

            function stortList() {
                // 门店
                $.ajax({
                    url: 'getStoreList.action',//
                    data: "",
                    type: 'post',
                    cache: false,
                    dataType: 'json',
                    success: function (data) {
                        var dataL = data.data;
                        var bool = data.ret;
                        var list = '';
                        $("#store_list").empty();
                        /* $("#store_list").find("option").remove(); */
                        var options = '<option value="0">全部</option>';
                        if (bool == 0 || bool == '0') {
                            for (var i = 0; i < dataL.length; i++) {
                                var datas = dataL[i];
                                options = options + '<option value="'
                                    + datas.code + '">'
                                    + datas.name + '</option>';
                            }

                        }
                        $("#store_list").append(options);
                        $("#store_list").trigger("chosen:updated");
                        $("#store_list").trigger("liszt:updated");
                        $("#store_list").chosen();
                    },
                    error: function () {
                        alert("页面数据加载失败！");
                    }
                });
            }

            /*******************************************************************
             * 自己封装的js end * *
             ******************************************************************/
        });

/*******************************************************************************
 *
 ******************************************************************************/
// 取消订单
function updateOrder(orderId, type, callback) {
    if (type == 4 || type == 7) {
        refunOrder(orderId, type, callback);
        return;
    }
    swal({
        title: "确定取消订单?" + orderId,
        text: "取消订单会退到被动取消里!",
        type: "warning",
        showCancelButton: true,
        cancelButtonText: "容我三思！",
        confirmButtonText: "确定!",
    }).then(function () {
        $.ajax({
            url: "updateOrder",              // 请求地址
            data: {
                "orderId": orderId,
                "type": type
            },
            type: 'post',
            cache: false,
            dataType: 'json',
            success: function (data) {
                swal("取消成功!", "", "success");
            },
            error: function () {
                swal("取消失败!", "请联系管理员处理", "error");
            }
        });

    }, function () {
	});
}
// 退款函数
function refunOrder(orderId, type, callback) {
    swal({
        title: "确定退款" + orderId,
        text: "退款之后金额直接打入对方账户!",
        type: "warning",
        showCancelButton: true,
        cancelButtonText: "容我三思！",
        confirmButtonText: "确定!",
    }).then(function () {
        $.ajax({
            url: "createdRefun.action",              // 请求地址
            data: {
                "orderId": orderId,
                "biaoshi": 1
            },
            type: 'post',
            cache: false,
            dataType: 'json',
            success: function (data) {
                swal("退款成功!", "您已退款成功,金额将打入对方账户", "success");
            },
            error: function () {
                swal("退款失败!", "请联系管理员处理", "error");
            }
        });

    }, function () {
	});
}

/** *********************************订单取消函数******************************************* */
function updateOrder2(orderId, type, _class) {
    var order_type_child = $("#order_type_child").val();
    var click_order_type = $("#click_order_type").val();
    var order_title = click_order_type;//$("#order_title strong").text();

    if (order_title != click_order_type)
        click_order_type = order_title;
    if (type == 1) {
        swal({
            title: "确定取消订单?" + orderId,
            text: "取消订单会退到被动取消里!",
            type: "warning",
            showCancelButton: true,
            cancelButtonText: "容我三思！",
            confirmButtonText: "确定!",
        }).then(function () {
            $.ajax({
                url: "updateOrder",              // 请求地址
                data: {
                    "orderId": orderId,
                    "type": type
                },
                type: 'post',
                cache: false,
                dataType: 'json',
                success: function (data) {
                    // 刷新页面，不刷新整体页面只是刷新table
                    // 刷新页面，不刷新整体页面只是刷新table
                    if (data.ret == 0 || data.ret == "0") {
                        if (click_order_type == "团体课程" || _class == "团体课程") {
                            getTKTable(click_order_type, order_type_child, 1, "", swal("取消成功!", "您已取消成功,取消订单里面", "success"));
                        } else if (click_order_type == "私教课程") {
                            getSJTable(click_order_type, order_type_child, 1, "", swal("取消成功!", "您已取消成功,取消订单里面", "success"));
                        } else if (click_order_type == "檬营课程") {
                            getMYTable(click_order_type, order_type_child, 1, "", swal("取消成功!", "您已取消成功,取消订单里面", "success"));
                        } else if (click_order_type == "自助健身") {
                            getZZTable(click_order_type, order_type_child, 1, "", swal("取消成功!", "您已取消成功,取消订单里面", "success"));
                        } else {
                            /*swal("取消成功!", "您已取消成功,取消订单里面", "success");
                             history.go(0);*/
                        }
                    }else{
                    	swal("取消失败!", "请联系管理员处理", "error");
                    }
                },
                error: function () {
                    swal("取消失败!", "请联系管理员处理", "error");
                }
            });

        }, function () {
		});

    } else {
        swal({
            title: "确定退款" + orderId,
            text: "退款之后金额直接打入对方账户!",
            type: "warning",
            showCancelButton: true,
            cancelButtonText: "容我三思！",
            confirmButtonText: "确定!",
        }).then(function () {

            $.ajax({
                url: "createdRefun.action",              // 请求地址
                data: {
                    "orderId": orderId,
                    "biaoshi": 1
                },
                type: 'post',
                cache: false,
                dataType: 'json',
                success: function (data) {
                    // 刷新页面，不刷新整体页面只是刷新table
                    if (data.ret == 0 || data.ret == "0") {
                        if (click_order_type == "团体课程") {
                            getTKTable(click_order_type, order_type_child, 1, "", swal("退款成功!", "您已退款成功,金额将打入对方账户", "success"));
                        } else if (click_order_type == "私教课程") {
                            getSJTable(click_order_type, order_type_child, 1, "", swal("退款成功!", "您已退款成功,金额将打入对方账户", "success"));
                        } else if (click_order_type == "檬营课程") {
                            getMYTable(click_order_type, order_type_child, 1, "", swal("退款成功!", "您已退款成功,金额将打入对方账户", "success"));
                        } else if (click_order_type == "自助健身") {
                            getZZTable(click_order_type, order_type_child, 1, "", swal("退款成功!", "您已退款成功,金额将打入对方账户", "success"));
                        }

                    }
                    if (data.ret == -1 || data.ret == "-1") {
                        swal(data.msg, "请联系管理员处理", "error");
                    }
                },
                error: function () {
                    swal("退款失败!", "请联系管理员处理", "error");
                }
            });

        }, function () {
		});
    }

}

// 刷新当前页面
function refreshHTML(type) {
    // 获取当前页面被点击的参数
    var order_type = $("#order_type").val();
    swal("刷新当前页面!", order_type, "error");
    return;
    window.location.reload();

}


// 请求的统一方法
function Ajax(url, data, callback) {
	$('.modal-loading').show();
    $.ajax({
        url: url,//
        data: data,
        type: 'post',
        cache: false,
        dataType: 'json',
        success: function (data) {
            callback(data);
            if (!callback) {
                callback(data);
            }
            $('.modal-loading').hide();
        },
        error: function () {
            alert("获取失败！");
            $('.modal-loading').hide();
        }
    });

}
/** ***************************************************团体课程************************************* */
function getTKTable(_class, type, pageNum, datas, callback) {
	$('.modal-loading').show();
	$("#tk_tongji").html("");
    $("#tk_feiyong").html("");
    $("#tk_shifu").html("");
    var biaoshi = 1;
    var th_title = '下订单时间';
    var tite = '取消';
    if (type == 4 || type == 7) {
        tite = '退款';
        biaoshi = 2;
        th_title = "下订单时间/取消时间";
    } else if (type == 5 || type == 6) {
        biaoshi = 3;
        tite = '';
        th_title = (type == 6 ? "下订单时间/退款时间" : th_title);
    } else {
        tite = '取消';
    }

    var _type = "";
    if (type == "") {
        _type = "1";
    } else {
        _type = type;
    }
    var params = "";
    if (datas == "") {
        params = {
            "type": _type,
            "pageNum": pageNum
        }
    } else {
        params = datas;
    }
    $("#tk_th").html(th_title);
    Ajax("getTeamOrderList", params, function (data) {
        var dataL = data.data.TkData;
        var trtd = '';
        var td_time = '';
        $('#td1').empty();
        if (data.ret == '-1') {
            swal("获取数据失败", "请联系管理员处理", "error");
            return;
        }
        for (var i = 0; i < dataL.length; i++) {
            var datas = dataL[i];
            var tds = "";
            var trs = '</tr>';
            var pay_type  = '';
            
            if(datas.pay_type == 3){
            	pay_type = '(企)';
            }else if(datas.pay_type == 2){
            	pay_type = '(储)';
            }else if(datas.pay_type == 1){
            	pay_type = '(微)';
            }else if(datas.pay_type == 4){
            	pay_type = "("+datas.weixinAmt+'_微/'+datas.consumeAmt+"_储)";
            }else if(datas.pay_type == 5){
            	pay_type = "("+datas.weixinAmt+'_微/'+datas.companyAmt+"_企)";
            }
            trtd = trtd
                + '<tr>'
                + '<td>' + (i + 1) + '</td>'
                + '<td>' + datas.trade_id + '</td>'
                + '<td>' + getDateByTypeTK(type, datas.created_time, datas.cancel_time, datas.refund_time) + '</td>'
                + '<td>' + datas.order_number + '</td>'
                + '<td>' + datas.title + '</td>'
                + '<td>' + new Date(datas.start_time).pattern("yyyy-MM-dd HH:mm:ss") + '</td>'
                + '<td>' + datas.coach_name + '</td>'
                + '<td>' + (datas.nick_name == null ? "" : datas.nick_name) + '</br>' + (datas.mobile == null ? "" : datas.mobile) + '</td>'
                + '<td>' + datas.level + '</td>'
                + '<td>' + datas.prime_price + '</td>'
                + '<td>' + (datas.cash_money == undefined ? "":datas.cash_money) + '</td>'
                + '<td>' + datas.person_count + '</td>'
                + '<td>' + datas.price1 +pay_type + '</td>'
                + '<td>' + datas.store_name + '</td>';
            if (type == 6 || type == 3 || type == 5) {
                tds = '';
            } else {
                if (datas.cancel_backmoney == 1 || datas.cancel_backmone == '1' || (datas.price1 == '0' && type == 1 || datas.price1 == 0 && type == 1)) {
                    tds = '<td ><button type="button" class="btn btn-default btn-sm" onclick="updateOrder2(' + datas.order_id + ',' + biaoshi + ')">'
                        + '<span class="glyphicon glyphicon-ban-circle"></span> ' + tite + '</button></span></td>';
                
                    if(datas.price1 == '0' && tite == '退款' || datas.price1 == 0 && tite == '退款'){
                    	tds = '';
                    }
                }
                else {
                    tds = '';
                }

            }
            trtd = trtd + tds + trs;
        }
        $('#td1').append(trtd);
        $("#tk_tongji").html("订单合计：" + data.data.pageCount + "笔");
        $("#tk_feiyong").html("费用合计：¥" + data.data.totalFee + "&nbsp;元");
        $("#tk_shifu").html("&nbsp;&nbsp;实付合计：¥" + data.data.totalPayment + "&nbsp;元");
        new Page({
            parent: $("#tk_page_list"),
            nowPage: data.data.pageNum,// 第几页
            pageSize: 20,// 每页条数
            totalCount: data.data.pageCount,// 总共有几条
            setting: {
                defaultPage: 7,// 默认显示可点击分页的个数 Math.floor(data.data.pageCount / 10)
                firstPageText: "首页",
                prevPageText: "上一页",
                nextPageText: "下一页",
                lastPageText: "尾页"
            },
            callback: function (nowPage, totalPage) {
                nowPage == "" ? nowPage : pageNum;
                var _time = $("#tk_time").val();
                var str = _time.split("~");
                var c_start_time = str[0];
                var c_end_time = str[1];
                var course_id = $("#tk_course").val();
                var mobile = $("#tk_mobile").val();
                var store_id = $("#tk_store_list").val();
                var click_order_type = $("#click_order_type").val();
                var order_type_child = $("#order_type_child").val();
                var coach_id = $("#tk_coach_list").val();
                var tradeId = $("#tk_tradeId").val();
                if (store_id == "0" || store_id == 0) {
                    store_id = "";
                }
                var datas = {
                    "course_stime": c_start_time,
                    "course_etime": c_end_time,
                    "course_id": course_id,
                    "mobile": mobile,
                    "store_id": store_id,
                    "type": order_type_child,
                    "tradeId": tradeId,
                    "coach_id": coach_id,
                    "pageNum": nowPage,
                    "type": type
                }
                getTKTable(_class, type, nowPage, datas, "");

            }
        });
        $('.modal-loading').hide();
        if (callback) {
            callback();
        }
    });
}

/** ***************************************************私教课程************************************* */
function getSJTable(_class, type, pageNum, datas, callback) {
    var params = "";
    var _type = "";
    if (type == 1 || type == 2) {
        tite = '销课';
        biaoshi = 2;
    } else {
        tite = '取消';
    }
    var params = "";
    if (datas == "") {
        params = {
            "type": type,
            "pageNum": pageNum
        }
    } else {
        params = datas;
    }
    // debugger;
    Ajax("get_personal_order_list", params, function (data) {
        var dataL = data.data.SjData;
        $("#sj_tongji").html("");
        $("#sj_feiyong").html("");
        $("#sj_shifu").html("");
        if (data.ret == '-1') {
            swal("获取数据失败", "请联系管理员处理", "error");
            return;
        }
        var trtd = "";
        $('#td2').empty();
        for (var i = 0; i < dataL.length; i++) {
            var datas = dataL[i];
            var tds = "";
            var trs = '</tr>';
            var pay_type = '';
            if(datas.pay_type == 3){
            	pay_type = '(企)';
            }else if(datas.pay_type == 2){
            	pay_type = '(储)';
            }else if(datas.pay_type == 1){
            	pay_type = '(微)';
            }else if(datas.pay_type == 4){
            	pay_type = "("+datas.weixinAmt+'_微/'+datas.consumeAmt+"_储)";
            }else if(datas.pay_type == 5){
            	pay_type = "("+datas.weixinAmt+'_微/'+datas.companyAmt+"_企)";
            }
            
            
            + '<td>' + datas.price1 +pay_type + '</td>'
            trtd = trtd
                + '<tr>'
                + '<td>' + (i + 1) + '</td>'
                + '<td>' + datas.trade_id + '</td>'
                + '<td>' + getDateByTypeSJ(type, datas.created_time, datas.cancel_time, datas.refund_time) + '</td>'
                + '<td>' + datas.order_number + '</td>'
                + '<td>' + datas.title + '</td>'
                + '<td>' + datas.coach_name + '</td>'
                + '<td>' + datas.nick_name + '</br>' + (datas.mobile == null ? "" : datas.mobile) + '</td>'
                + '<td>' + datas.level + '</td>'
                + '<td>' + datas.prime_price + '</td>'
                + '<td>' + (datas.cash_money == undefined ? "":datas.cash_money) + '</td>'
                + '<td>' + datas.person_count + '</td>'
                + '<td>' + datas.price1 +pay_type + '</td>'
                + '<td>' + datas.periods + '</td>'
                + '<td>' + datas.overplus_periods + '</td>';
            if (type == 1) {
                if (datas.cancel_backmoney == 0 || datas.cancel_backmoney == '0') {
                    tds = '';
                    if (datas.price1 == '0' || datas.price1 == 0) {
                        tds = '<td>' + '<a href="to_course_dispel.action?orderId=' + datas.order_id + '">'
                            + '<button type="button" class="btn btn-default btn-sm" >'
                            + '<span class="glyphicon glyphicon-ban-circle"></span>销课</button></span></a></td>';
                    }
                } else {
                    tds = '<td>' + '<a href="to_course_dispel.action?orderId=' + datas.order_id + '">'
                        + '<button type="button" class="btn btn-default btn-sm" >'
                        + '<span class="glyphicon glyphicon-ban-circle"></span>' + tite + '</button></span></a></td>';
                }
            } else {
                tds = '';
            }
            trtd = trtd + tds + trs;
        }
        $('#td2').append(trtd);
        $("#sj_tongji").html("订单合计：" + data.data.pageCount + "笔");
        $("#sj_feiyong").html("费用合计：¥" + data.data.totalFee + "&nbsp;元");
        $("#sj_shifu").html("&nbsp;&nbsp;实付合计：¥" + data.data.totalPayment + "&nbsp;元");
        new Page({
            parent: $("#sj_page_list"),
            nowPage: data.data.pageNum,// 第几页
            pageSize: 20,// 每页条数
            totalCount: data.data.pageCount,// 总共有几条
            setting: {
                defaultPage: 7,// 默认显示可点击分页的个数Math.floor(data.data.pageCount / 10)
                firstPageText: "首页",
                prevPageText: "上一页",
                nextPageText: "下一页",
                lastPageText: "尾页"
            },
            callback: function (nowPage, totalPage) {
                nowPage == "" ? nowPage : pageNum;
                var tradeId = $("#sj_tradeId").val();
                var _time = $("#sj_time").val();
                var str = _time.split("~");
                var c_start_time = str[0];
                var c_end_time = str[1];
                var course_id = $("#sj_course").val();
                var mobile = $("#sj_mobile").val();
                var store_id = $("#sj_store_list").val();
                var click_order_type = $("#click_order_type").val();
                var order_type_child = $("#order_type_child").val();
                var coach_id = $("#sj_coach_list").val();
                var tradeId = $("#sj_tradeId").val();
                if (store_id == "0" || store_id == 0) {
                    store_id = "";
                }
                var datas = {
                    "course_stime": c_start_time,
                    "course_etime": c_end_time,
                    "course_id": course_id,
                    "mobile": mobile,
                    "store_id": store_id,
                    "type": order_type_child,
                    "tradeId": tradeId,
                    "coach_id": coach_id,
                    "pageNum": nowPage,
                    "type": type
                }
                getSJTable(_class, type, nowPage, datas, "");
            }
        });
        if (callback) {
            callback();
        }
    });
}

/** ***************************************************训练营************************************* */
function getMYTable(_class, type, pageNum, datas, callback) {
    var biaoshi = 1;
    var tite = '取消';
    var params = "";
    if (type == 5 || type == 7) {
        tite = '退款';
        biaoshi = 2;
    } else if (type == 6) {
        tite = '';
    } else {
        tite = '取消';
    }

    var _type = "";
    if (type == "") {
        _type = "1";
    } else {
        _type = type;
    }
    if (datas == "") {
        params = {
            "type": _type,
            "pageNum": pageNum
        }
    } else {
        params = datas;
    }
    // 训练营

    Ajax("get_fun_camp_order_list", params, function (data) {
        $("#my_tongji").html("");
        $("#my_feiyong").html("");
        $("#my_shifu").html("");
        var dataL = data.data.MyData;
        if (data.ret == '-1') {
            swal("获取数据失败", "请联系管理员处理", "error");
            return;
        }
        var trtd = "";
        $('#td3').empty();
        for (var i = 0; i < dataL.length; i++) {
            var datas = dataL[i];
            var tds = "";
            var trs = '</tr>';
            var pay_type = '';
            if(datas.pay_type == 3){
            	pay_type = '(企)';
            }else if(datas.pay_type == 2){
            	pay_type = '(储)';
            }else if(datas.pay_type == 1){
            	pay_type = '(微)';
            }else if(datas.pay_type == 4){
            	pay_type = "("+datas.weixinAmt+'_微/'+datas.consumeAmt+"_储)";
            }else if(datas.pay_type == 5){
            	pay_type = "("+datas.weixinAmt+'_微/'+datas.companyAmt+"_企)";
            }
            
            trtd = trtd
                + '<tr>'
                + '<td>' + (i + 1) + '</td>'
                + '<td>' + datas.trade_id + '</td>'
                + '<td>' + getDateByTypeMY(type, datas.created_time, datas.cancel_time, datas.refund_time) + '</td>'
                + '<td>' + datas.order_number + '</td>'
                + '<td>' + datas.title + '</td>'
                + '<td>' + new Date(datas.start_time).pattern("yyyy-MM-dd HH:mm:ss") + '</td>'
                + '<td>' + datas.nick_name + '</br>' + (datas.mobile == null ? "" : datas.mobile) + '</td>'
                + '<td>' + datas.level + '</td>'
                + '<td>' + datas.prime_price + '</td>'
                + '<td>' + (datas.cash_money == undefined ? "":datas.cash_money) + '</td>'
                + '<td>' + datas.person_count + '</td>'
                + '<td>' + datas.price1 +pay_type + '</td>'
                + '<td>' + datas.store_name + '</td>';
            if (type == 3 || type == 4 || type == 6) {
                tds = '';
            } else {
                if (datas.cancel_backmoney == 0 || datas.cancel_backmoney == '0') {
                    tds = '';
                    if ((datas.price1 == '0' && type == 1 || datas.price1 == 0 && type == 1)) {
                        tds = '<td>' + '<button type="button" class="btn btn-default btn-sm" onclick="updateOrder2(' + datas.order_id + ',' + biaoshi + ')">'
                            + '<span class="glyphicon glyphicon-ban-circle"></span>' + tite + '</button></span></td>';
                    }
                } else {
                    tds = '<td>' + '<button type="button" class="btn btn-default btn-sm" onclick="updateOrder2(' + datas.order_id + ',' + biaoshi + ')">'
                        + '<span class="glyphicon glyphicon-ban-circle"></span>' + tite + '</button></span></td>';
                    if(datas.price1 == '0'&& tite == '退款' || datas.price1 == 0 && tite == '退款' ){
                    	tds = '';
                    }
                }
            }
            trtd = trtd + tds + trs;
        }
        $('#td3').append(trtd);
        $("#my_tongji").html("订单合计：" + data.data.pageCount + "笔");
        $("#my_feiyong").html("费用合计：¥" + data.data.feiyong + "&nbsp;元");
        $("#my_shifu").html("&nbsp;&nbsp;实付合计：¥" + data.data.shifu + "&nbsp;元");
        new Page({
            parent: $("#my_page_list"),
            nowPage: data.data.pageNum,// 第几页
            pageSize: 20,// 每页条数
            totalCount: data.data.pageCount,// 总共有几条
            setting: {
                defaultPage: 7,// 默认显示可点击分页的个数Math.floor(data.data.pageCount / 10)
                firstPageText: "首页",
                prevPageText: "上一页",
                nextPageText: "下一页",
                lastPageText: "尾页"
            },
            callback: function (nowPage, totalPage) {
                nowPage == "" ? nowPage : pageNum;
                var _time = $("#my_time").val();
                var tradeId = $("#my_tradeId").val();
                var str = _time.split("~");
                var c_start_time = str[0];
                var c_end_time = str[1];
                var course_id = $("#my_course").val();
                var mobile = $("#my_mobile").val();
                var store_id = $("#my_store_list").val();
                var click_order_type = $("#click_order_type").val();
                var order_type_child = $("#order_type_child").val();
                var tradeId = $("#my_tradeId").val();
                if (store_id == "0" || store_id == 0) {
                    store_id = "";
                }
                var datas = {
                    "course_stime": c_start_time,
                    "course_etime": c_end_time,
                    "course_id": course_id,
                    "mobile": mobile,
                    "store_id": store_id,
                    "type": order_type_child,
                    "tradeId": tradeId,
                    "pageNum": nowPage,
                    "type": type
                }
                getMYTable(_class, type, nowPage, datas, "");
            }
        });
        if (callback) {
            callback();
        }
    });
}
/** ***************************************************自助健身的函数************************************* */
function getZZTable(_class, type, pageNum, datas, callback) {
    var tite = '取消';
    var biaoshi = 1;
    var params = "";
    if (type == 4) {
        tite = '退款';
        biaoshi = 2;
    } else if (type == 5) {
        tite = '';
    } else {
        tite = '取消';
    }

    var _type = "";
    if (type == "") {
        _type = "1";
    } else {
        _type = type;
    }
    // 自助健身
    if (datas == "") {
        params = {
            "type": _type,
            "pageNum": pageNum
        }
    } else {
        params = datas;
    }

    Ajax("get_self_order_list", params, function (data) {
        $("#zz_tongji").html("");
        $("#zz_feiyong").html("");
        $("#zz_shifu").html("");

        $('#td4').empty();
        var dataL = data.data.ZzData;
        if (data.ret == '-1') {
            swal("获取数据失败", "请联系管理员处理", "error");
            return;
        }
        if (data.msg == "无自助健身退款订单") {
            return false;
        }
        var trtd = "";
        $('#td4').empty();
        for (var i = 0; i < dataL.length; i++) {
            var datas = dataL[i];
            var tds = "";
            var trs = '</tr>';
            var pay_type = '';
            if(datas.pay_type == 3){
            	pay_type = '(企)';
            }else if(datas.pay_type == 2){
            	pay_type = '(储)';
            }else if(datas.pay_type == 1){
            	pay_type = '(微)';
            }else if(datas.pay_type == 4){
            	pay_type = "("+datas.weixinAmt+'_微/'+datas.consumeAmt+"_储)";
            }else if(datas.pay_type == 5){
            	pay_type = "("+datas.weixinAmt+'_微/'+datas.companyAmt+"_企)";
            }
            
            trtd = trtd
                + '<tr>'
                + '<td>' + (i + 1) + '</td>'
                + '<td>' + datas.trade_id + '</td>'
                + '<td>' + getDateByTypeZZ(type, datas.created_time, datas.cancel_time, datas.refund_time) + '</td>'
                + '<td>' + (datas.order_number == undefined ? "" : datas.order_number) + '</td>'
                + '<td>' + (datas.periods == undefined ? "" : datas.periods) + '</td>'
                + '<td>' + datas.store_name + '</td>'
                + '<td>' + datas.nick_name + '</br>' + (datas.mobile == null ? "" : datas.mobile) + '</td>'
                + '<td>' + datas.level + '</td>'
                + '<td>' + datas.prime_price + '</td>'
                + '<td>' + (datas.cash_money == undefined ? "":datas.cash_money) + '</td>'
                + '<td>' + datas.person_count + '</td>'
                + '<td>' + datas.price1 +pay_type + '</td>'
            if (type == 5 || type == 2 || type == 3) {
                tds = '';
            } else {
                if (datas.cancel_backmoney == 0 || datas.cancel_backmoney == '0')
                    tds = '';
                if (datas.price1 == '0' && type == 1 || datas.price1 == 0 && type == 1) {
                    tds = '<td>' + '<button type="button" class="btn btn-default btn-sm" onclick="updateOrder2(' + datas.order_id + ',' + biaoshi + ')">'
                        + '<span class="glyphicon glyphicon-ban-circle"></span>' + tite + '</button></span></td>';
                }
                else {
                	if(datas.cancel_backmoney == 0 && type == 4 || datas.cancel_backmoney == 0 && type == "4"){
                		tds = '';
                	}else{
                		tds = '<td>' + '<button type="button" class="btn btn-default btn-sm" onclick="updateOrder2(' + datas.order_id + ',' + biaoshi + ')"">'
                        + '<span class="glyphicon glyphicon-ban-circle"></span>' + tite + '</button></span></td>';
                	}
                    
                }

            }
            trtd = trtd + tds + trs;
        }
        $('#td4').append(trtd);
        $("#zz_tongji").html("订单合计：" + data.data.pageCount + "笔");
        $("#zz_feiyong").html("费用合计：¥" + data.data.feiyong + "&nbsp;元");
        $("#zz_shifu").html("&nbsp;&nbsp;实付合计：¥" + data.data.shifu + "&nbsp;元");
        new Page({
            parent: $("#zz_page_list"),
            nowPage: data.data.pageNum,// 第几页
            pageSize: 20,// 每页条数
            totalCount: data.data.pageCount,// 总共有几条
            setting: {
                defaultPage: 7,// 默认显示可点击分页的个数Math.floor(data.data.pageCount / 10)
                firstPageText: "首页",
                prevPageText: "上一页",
                nextPageText: "下一页",
                lastPageText: "尾页"
            },
            callback: function (nowPage, totalPage) {
                nowPage == "" ? nowPage : pageNum;
                var tradeId = $("#zz_tradeId").val();
                var _time = $("#zz_time").val();
                var str = _time.split("~");
                var c_start_time = str[0];
                var c_end_time = str[1];
                var course_id = $("#zz_course").val();
                var mobile = $("#zz_mobile").val();
                var store_id = $("#zz_stort_list").val();
                var click_order_type = $("#click_order_type").val();
                var order_type_child = $("#order_type_child").val();
                var tradeId = $("#tradeId").val();
                if (store_id == "0" || store_id == 0) {
                    store_id = "";
                }
                var datas = {
                    "course_stime": c_start_time,
                    "course_etime": c_end_time,
                    "course_id": course_id,
                    "mobile": mobile,
                    "store_id": store_id,
                    "type": order_type_child,
                    "tradeId": tradeId,
                    "pageNum": nowPage,
                    "type": type
                }
                getZZTable(_class, type, nowPage, datas, "");
            }
        });
        if (callback) {
            callback();
        }
    });
}
/** ***************************************************用户消费明细查询************************************* */
function getUserTable(_class, type, pageNum, datas, callback){
	 if (datas == "") {
	        params = {
	            "pageNo": pageNum
	        }
	    } else {
	        params = datas;
	  }
	Ajax("query_user_order.action", params, function (data) {
        $("#u_tongji").html("");
        $("#u_feiyong").html("");
        $("#u_shifu").html("");
        $('#td6').empty();
        var dataL = data.data.list;
        
        if (data.ret == '-1') {
            swal("获取数据失败", "请联系管理员处理", "error");
            return;
        }
        var trtd = "";
        $('#td6').empty();
        debugger;
        for (var i = 0; i < dataL.length; i++) {
            var datas = dataL[i];
            var tds = "";
            var trs = '</tr>';
            trtd = trtd 
            	+'<td>'+(1+i)+'</td>'
            	+'<td>'+datas.orderNumber+'</td>'
            	+'<td>'+datas.title+'</td>'
            	+'<td>'+datas.storeName+'</td>'
            	+'<td>'+datas.primePrice+'</td>'
            	+'<td>'+datas.amount+'</td>'
            	+'<td>'+(datas.couponDetailId==null?'无':datas.couponDetailId)+'</td>'
            	+'<td>'+datas.payType+'</td>'
            	+'<td>'+datas.orderType+'</td>'
            	+'<td>'+datas.payStatus+'</td>'
            	+'<td>'+datas.createdTime+'</td>'
            trtd = "<tr>"+trtd + tds + trs;
        }
        $('#td6').append(trtd);
        $("#u_tongji").html("订单合计：" + data.data.pageCount + "笔");
        $("#u_feiyong").html("费用合计：¥" + data.data.feiyong + "&nbsp;元");
        $("#u_shifu").html("&nbsp;&nbsp;实付合计：¥" + data.data.shifu + "&nbsp;元");
        new Page({
            parent: $("#u_page_list"),
            nowPage: data.data.pageNow,// 第几页
            pageSize: 20,// 每页条数
            totalCount: data.data.pageCount,// 总共有几条
            setting: {
                defaultPage: 7,
                firstPageText: "首页",
                prevPageText: "上一页",
                nextPageText: "下一页",
                lastPageText: "尾页"
            },
            callback: function (nowPage, totalPage) {
                nowPage == "" ? nowPage : pageNum;
                params.pageNo = nowPage;
                $("#u_pageNo").val(nowPage);
                getUserTable("", "", nowPage, params, "");
            }
        });
        if (callback) {
            callback();
        }
    });
}
/** ****************************分页方法 分页函数************************** */
function pageF(pageIds, pageNum, pageCount) {
    var pageId = "#" + pageId;
    new Page({
        parent: $("#" + pageId),
        nowPage: pageNum,// 第几页
        pageSize: 20,// 每页条数
        totalCount: pageCount,// 总共有几条
        setting: {
            defaultPage: dataL.length / 10,// 默认显示可点击分页的个数
            firstPageText: "首页",
            prevPageText: "上一页",
            nextPageText: "下一页",
            lastPageText: "尾页"
        },
        callback: function (nowPage, totalPage) {
            pageF();
        }
    });
}
// 模仿被点击时间跳到某个瞄点
function miaodian() {
    var md = getQueryString("miaodian");
    // debugger;
    switch (md) {
        case "1":
            $("#tt_class").click();
            break;
        case "2":
            $("#sj_class").click();

            break;
        case "3":
            $("#my_class").click();
        case "4":
            $("#zz_class").click();
            break;
        default:
    }

}
// 解析URl
function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
}
/**
 * 团课
 * @param type 类型
 * @param time1 下单时间
 * @param time2 修改时间
 * @param time3 退款时间
 * @returns
 */
function getDateByTypeTK(type, time1, time2, time3) {
    var time = '';
    if (type == 4 || type == 7) {
        time = new Date(time1).pattern("yyyy-MM-dd HH:mm:ss") + '(下单)</br>' + new Date(time2).pattern("yyyy-MM-dd HH:mm:ss") + '(取消)';

    } else if (type == 6) {
        time = new Date(time1).pattern("yyyy-MM-dd HH:mm:ss") + '(下单)</br>' + new Date(time3).pattern("yyyy-MM-dd HH:mm:ss") + '(退款)';
    } else {
        time = new Date(time1).pattern("yyyy-MM-dd HH:mm:ss");
    }
    return time;
}
/**
 * 私教
 * @param type 类型
 * @param time1 下单时间
 * @param time2 修改时间
 * @param time3 退款时间
 * @returns
 */
function getDateByTypeSJ(type, time1, time2, time3) {
    var time = '';
    if (type == 4) {
        time = new Date(time1).pattern("yyyy-MM-dd HH:mm:ss") + '(下单)</br>' + new Date(time3).pattern("yyyy-MM-dd HH:mm:ss") + '(退款)';
    } else {
        time = new Date(time1).pattern("yyyy-MM-dd HH:mm:ss");
    }
    return time;
}
/**
 * 训练营
 * @param type 类型
 * @param time1 下单时间
 * @param time2 修改时间
 * @param time3 退款时间
 * @returns
 */
function getDateByTypeMY(type, time1, time2, time3) {
    var time = '';
    if (type == 5 || type == 7) {
        time = new Date(time1).pattern("yyyy-MM-dd HH:mm:ss") + '(下单)</br>' + new Date(time2).pattern("yyyy-MM-dd HH:mm:ss") + '(取消)';

    } else if (type == 6) {
        time = new Date(time1).pattern("yyyy-MM-dd HH:mm:ss") + '(下单)</br>' + new Date(time3).pattern("yyyy-MM-dd HH:mm:ss") + '(退款)';
    } else {
        time = new Date(time1).pattern("yyyy-MM-dd HH:mm:ss");
    }
    return time;
}
/**
 * 自助健身
 * @param type 类型
 * @param time1 下单时间
 * @param time2 修改时间
 * @param time3 退款时间
 * @returns
 */
function getDateByTypeZZ(type, time1, time2, time3) {
    var time = '';
    if (type == 4) {
        time = new Date(time1).pattern("yyyy-MM-dd HH:mm:ss") + '(下单)</br>' + new Date(time2).pattern("yyyy-MM-dd HH:mm:ss") + '(取消)';

    } else if (type == 5) {
        time = new Date(time1).pattern("yyyy-MM-dd HH:mm:ss") + '(下单)</br>' + new Date(time3).pattern("yyyy-MM-dd HH:mm:ss") + '(退款)';
    } else {
        time = new Date(time1).pattern("yyyy-MM-dd HH:mm:ss");
    }
    return time;
}

function coachList() {
    $.ajax({
        url: 'get_coach_list',//
        data: "",
        type: 'post',
        cache: false,
        dataType: 'json',
        success: function (data) {
            var dataL = data.data;
            var bool = data.ret;
            var list = '';
            $(".coach_list").empty();
            var options = '<option value="0">全部</option>';
            if (bool == 0 || bool == '0') {
                for (var i = 0; i < dataL.length; i++) {
                    var datas = dataL[i];
                    options = options + '<option value="'
                        + datas.id + '">'
                        + datas.nickName + '</option>';
                }

            }
            // 团课
            $(".coach_list").append(options);
            $(".coach_list").trigger("chosen:updated");
            $(".coach_list").chosen();

        },
        error: function () {
            alert("页面数据加载失败！");
        }
    });
}
/**************************************************************************************************************
 *                                                        导出函数start
 **************************************************************************************************************/
//团课导出
function tkExport(type) {
    baseUrl = $("#baseUrl").val();
    alert(baseUrl);
    var columnName = '';
    var keys = '';
    if (type == 1) {
    	columnName = '交易编号,下订单时间,订单号,课程名称,开课时间,教练,用户,身份,费用,优惠券,购买人数,实付,门店';
        keys = 'trade_id,created_time,order_number,title,start_time,coach_name,nick_name,level,prime_price,cash_money,person_count,price1,store_name';
    }
    if (type == 2) {
    	columnName = '交易编号,下订单时间,订单号,课程名称,教练,用户,身份,费用,优惠券,购买人数,实付,课时,消耗';
        keys = 'trade_id,created_time,order_number,title,coach_name,nick_name,level,prime_price,cash_money,person_count,price1,periods,overplus_periods';
    }
    if (type == 3) {
    	columnName = '交易编号,下订单时间,订单号,课程名称,开始时间,用户,身份,费用,优惠券,购买人数,实付,门店';
        keys = 'trade_id,created_time,order_number,title,start_time,nick_name,level,prime_price,cash_money,person_count,price1,store_name';
    }
    if (type == 4) {
    	columnName = '交易编号,下订单时间,订单号,时间段,门店,用户,身份,费用,优惠券,购买人数,实付';
        keys = 'trade_id,created_time,order_number,periods,store_name,nick_name,level,prime_price,cash_money,person_count,price1';
    }
    debugger;
    window.location = baseUrl + 'system/order/execl_order_tk.action?type=' + type + "&columnName=" + columnName+"&key="+keys;
}

function tkString() {
    var str = '交易编号,下订单时间,订单号,课程名称,开课时间,教练,用户,身份,费用,优惠券,购买人数,实付,门店';
    return str;
}

function sjString() {
    var str = '交易编号,下订单时间,订单号,课程名称,教练,用户,身份,费用,优惠券,购买人数,实付,课时,消耗';
    return str;
}

function myString() {
    var str = '交易编号,下订单时间,订单号,课程名称,开始时间,用户,身份,费用,优惠券,购买人数,实付,门店';
    return str;
}

function zzString() {

    var str = '交易编号,下订单时间,订单号,时间段,门店,用户,身份,费用,优惠券,购买人数,实付';
    return str;
}
/**************************************************************************************************************
 *                                                        导出函数 end
 **************************************************************************************************************/





